﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Outpatient.Migrations
{
    /// <inheritdoc />
    public partial class add_table_OtpMdtrtAssocOrd : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<decimal>(
                name: "AdvAmt",
                schema: "Outpatient",
                table: "OtpOrdRec",
                type: "numeric",
                nullable: false,
                defaultValue: 0m);

            migrationBuilder.AddColumn<decimal>(
                name: "SelfpayAmt",
                schema: "Outpatient",
                table: "OtpOrdRec",
                type: "numeric",
                nullable: false,
                defaultValue: 0m);

            migrationBuilder.CreateTable(
                name: "OtpMdtrtAssocOrd",
                schema: "Outpatient",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    OtpRxRecId = table.Column<Guid>(type: "uuid", nullable: false),
                    Rxno = table.Column<string>(type: "text", nullable: false),
                    OrdNo = table.Column<Guid>(type: "uuid", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OtpMdtrtAssocOrd", x => x.Id);
                    table.ForeignKey(
                        name: "FK_OtpMdtrtAssocOrd_OtpRxRec_OtpRxRecId",
                        column: x => x.OtpRxRecId,
                        principalSchema: "Outpatient",
                        principalTable: "OtpRxRec",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_OtpMdtrtAssocOrd_OtpRxRecId",
                schema: "Outpatient",
                table: "OtpMdtrtAssocOrd",
                column: "OtpRxRecId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "OtpMdtrtAssocOrd",
                schema: "Outpatient");

            migrationBuilder.DropColumn(
                name: "AdvAmt",
                schema: "Outpatient",
                table: "OtpOrdRec");

            migrationBuilder.DropColumn(
                name: "SelfpayAmt",
                schema: "Outpatient",
                table: "OtpOrdRec");
        }
    }
}
